package com.ylpms.agme.dao;

import com.ylpms.agme.entity.AreaEntity;
import com.ylpms.too.StringTool;
import com.ylpms.too.Table;
import com.ylpms.user.dao.UserDao;
import com.ylpms.user.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/****
 * 行政区域数据库操作接口
 * add by heyao 2019.01.20
 */
@Mapper
public interface AreaDao {

    @Insert("insert into t_agme_areainfo (areacode,areaname,description,parentid) values(#{areaEntity.areacode},#{areaEntity.areaname},#{areaEntity.description},#{areaEntity.parentid})")
    int saveArea(@Param("areaEntity") AreaEntity areaEntity);

    @Select("select * from t_agme_areainfo")
    List<AreaEntity> getAllAreaEntity();

    @Select("select * from t_agme_areainfo where id=#{id}")
    AreaEntity getAreaEntityById(@Param("id")int id);

    @Select("select * from t_agme_areainfo where areacode=#{areacode}")
    AreaEntity getAreaEntityByCode(@Param("areacode")String areacode);

    @Update("UPDATE t_agme_areainfo SET areacode=#{areaEntity.areacode}, areaname=#{areaEntity.areaname},description=#{areaEntity.description},parentid=#{areaEntity.parentid} WHERE id=#{areaEntity.id}")
    int updateAreaEntity(@Param("areaEntity")AreaEntity areaEntity);

}
